package com.shenbh.ribbon;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by 123430134@qq.com on 2018/2/11.
 */
@RestController
public class HelloService {


    @Autowired
    private RestTemplate restTemplate1;


    @Autowired
    @Qualifier("ribbonRestTemplate")
    @LoadBalanced
    public RestTemplate ribbonRestTemplate;

    @RequestMapping("/callHi")
    public String callHi(){
        return  restTemplate1.getForObject("http://127.0.0.1:8082/hi?name=callHi",String.class);
    }

    @RequestMapping("/ribbonCallHi")
    public String ribbonCallHi(){
        return  ribbonRestTemplate.getForObject("http://service-hi/hi?name=ribbonCallHii",String.class);
    }
}
